var taskData = require('../../data/taskList-data.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isSelectedNew: false,
    isSelectedPop: false,
    isSelectedNum: false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.onNewTask();
    var taskType = options.taskType;
    var taskLists = [];
    for (var i = 0; i < taskData.taskList.length; i++){
      if (taskData.taskList[i].taskType === taskType){
        taskLists.push(taskData.taskList[i]);
      }
    }
    this.setData({
      taskList: taskLists
    });
  },

  onTaskDetail: function (event) {
    var taskType = event.currentTarget.dataset.tasktype;
    switch (taskType) {
      case 'image':
        // wx.navigateTo({
        //   url: '/pages/imgTaskDetail/imgTaskDetail'
        // });
        // break;
      case 'voice':
        wx.navigateTo({
          url: '/pages/imgTaskDetail/imgTaskDetail?taskType=' + taskType
        });
      break;
      default:
        break;
    }
  },
  onNewTask: function (event) {
    this.setData({
      isSelectedNew: true,
      isSelectedPop: false,
      isSelectedNum: false
    });
  },

  onPopTask: function (event) {
    this.setData({
      isSelectedPop: true,
      isSelectedNum: false,
      isSelectedNew: false
    });
  },

  onTaskNum: function (event) {
    this.setData({
      isSelectedNum: true,
      isSelectedPop: false,
      isSelectedNew: false
    });
  }
})